package com.app.springbootinit.service.impl;


import com.app.springbootinit.mapper.ProductsMapper;
import com.app.springbootinit.model.Products;
import com.app.springbootinit.service.ProductsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 86184
* @description 针对表【products】的数据库操作Service实现
* @createDate 2024-12-13 21:52:32
*/
@Service
public class ProductsServiceImpl extends ServiceImpl<ProductsMapper, Products>
    implements ProductsService {
    @Resource
    private ProductsMapper productMapper;

    @Override
    public boolean saveProduct(Products product) {

        return productMapper.insert(product) > 0;
    }

    @Override
    public boolean removeProductById(int id) {
        return productMapper.deleteById(id) > 0;
    }

    @Override
    public boolean updateProduct(Products product) {
        return productMapper.updateById(product) > 0;
    }

    @Override
    public Products getProductById(int id) {
        return productMapper.selectById(id);
    }

    @Override
    public List<Products> listAllProducts() {
        return productMapper.selectList(null);
    }
}




